package pearson.automation.forms;

import org.openqa.selenium.By;

import framework.BaseForm;
import framework.elements.Button;
import framework.elements.ComboBox;
import framework.elements.Label;

public class AddLibraryForm extends BaseForm {
    private static Label identifier = new Label(
            By.xpath("//header[contains(.,'Add library item')]"),
            "Add library item");

    private ComboBox courseModules = new ComboBox(
            By.name("module"), "Course modules");
    private Button cancel = new Button(
            By.name("_cancel"), "Cancel");
    private Button select = new Button(
            By.xpath("//input[@value='Select']"), "Submit");

    public AddLibraryForm() {
        super(identifier.getLocator(), "Add library item");
    }

    public final void selectModule(final String moduleName) {
        courseModules.selectByText(moduleName);
    }

    public final MyLibraryForm clickCancel() {
        cancel.clickAndWait();
        return new MyLibraryForm();
    }

    public final MyLibraryForm clickSelect() {
        select.clickAndWait();
        return new MyLibraryForm();
    }
}
